﻿#region 头注释
/******************************************************************************
文件名称    :   OpticsService.cs
创建日期    :   2011-4-23 21:59:23
功能描述    :   Optics实体数据服务类
修改日志    :   
    2011-04-23 21:59  马利
*******************************************************************************/
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using Stone.Components.Entities;
using Dare.Utilities.Data;
using Stone.Data.Providers;

namespace Stone.Services.EntityServices
{
    /// <summary>
    /// Optics实体数据服务类
    /// </summary>
    public class OpticsService : EntityServiceTemplate<Optics, long, OpticsDataProvider>
    {
        public OpticsService(Application app)
            : base(app)
        {
        }

        public bool DeleteOpticsInfo(Optics optics)
        {
            MediaFileService mediaFileService = Stone.Services.Application.Instance.GetDbService<MediaFileService>();

            try
            {
                if (optics.TypeBUltrasonicFileId.HasValue) mediaFileService.Delete(optics.TypeBUltrasonicFileId.Value);
                if (optics.CTFileId.HasValue) mediaFileService.Delete(optics.CTFileId.Value);
                if (optics.CTUFileId.HasValue) mediaFileService.Delete(optics.CTUFileId.Value);
                if (optics.KUBIVPFileId.HasValue) mediaFileService.Delete(optics.KUBIVPFileId.Value);
                if (optics.ECTFileId.HasValue) mediaFileService.Delete(optics.ECTFileId.Value);

                return Delete(optics.Id);
            }
            catch
            {
                return false;
            }
        }

    }
}
